var content = document.querySelector('.content');
var container = document.querySelector('.container');
var yesBtn = document.getElementById('yesBtn');

content.addEventListener('mouseenter', function() {
  content.style.transition = 'background-color 0.3s';
  content.style.backgroundColor = 'rgba(100,100,100,0.5)'; // 将透明度更改为 0.5，使背景色加深
});

content.addEventListener('mouseleave', function() {
  content.style.transition = 'background-color 0.3s';
  content.style.backgroundColor = 'rgba(100,100,100,0.2)'; // 将透明度恢复为 0.2，使背景色变浅
});

// script.js

  var links = document.querySelectorAll('.sidebar ul li a');

  for (var i = 0; i < links.length; i++) {
    links[i].addEventListener('mouseenter', function() {
      this.style.transition = '0.2s';
      this.style.backgroundColor = '#679';
      this.style.borderRadius = '10px'; // 设置边缘的圆角半径为10px
    });

    links[i].addEventListener('mouseleave', function() {
      this.style.transition = '0.2s';
      this.style.backgroundColor = '';
      this.style.borderRadius = '10px'; // 鼠标移出时恢复原始边缘
    });
  }

yesBtn.addEventListener('click', function() {
  var selectElement = document.getElementById("course");
  var selectedValue = selectElement.value;
  //test
  console.log(selectedValue);
  //window.location.href = "livlogin_menu.html?c="+selectedValue;
  //test
  $.ajax({
    url: '/management/onsiteservlet/ossChooseCourse',              //接口：保存选择的课程到后端session
    method: 'POST',
    data: {
      selectedCourse: selectedValue
    },
    success: function(response) {
      // 处理响应数据
      if (response.flag) {
        // 成功处理逻辑

        alert("您已选择课程！");
      } else {

      }
    },
    error: function(xhr, status, error) {
      // 处理错误
    }
  });
});

document.addEventListener("DOMContentLoaded", function() {

    $.ajax({
       url: '/management/onsiteservlet/ossMenu',                 // 获取下拉列表 接口
       method: 'POST',
       success: function(response) {
         $('#course').empty();
         var data = response.data;
         $.each(data, function(index, value) {
           var option = $('<option>').text(value);
           $('#course').append(option);
         });
       },
       error: function(xhr, status, error) {
         console.log(error);
       }
    });
});